package com.ykdl.app.main.fragments;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.flyco.animation.BaseAnimatorSet;
import com.flyco.animation.BounceTopEnter;
import com.flyco.animation.NormalDialog;
import com.flyco.animation.OnBtnClickL;
import com.flyco.animation.SlideBottomExit;
import com.litesuits.http.LiteHttp;
import com.ykdl.app.R;
import com.ykdl.app.base.BaseFragment;
import com.ykdl.app.common.MyApplication;
import com.ykdl.app.login.LoginActivity;
import com.ykdl.app.main.BindPhoneActivity;
import com.ykdl.app.main.ModifyPasswordActivity;

public class SettingFragment extends BaseFragment implements OnClickListener {

	private LiteHttp client;
	private View convertView = null;
	private TextView zhanghao, name;

	@Override
	protected void onNewCreateView(View view) {
		// TODO Auto-generated method stub
		client = MyApplication.getInstance().getLiteHttp();
		convertView = view;
		setCenterView(R.layout.fragment_setting);
		initView();
		getData();
	}

	private void getData() {
		// TODO Auto-generated method stub

	}

	private void initView() {
		// TODO Auto-generated method stub
		zhanghao = (TextView) convertView.findViewById(R.id.zhanghao);
		name = (TextView) convertView.findViewById(R.id.name);
		convertView.findViewById(R.id.modify_pw).setOnClickListener(this);
		convertView.findViewById(R.id.bind_phone).setOnClickListener(this);
		convertView.findViewById(R.id.exit).setOnClickListener(this);
	}

	@Override
	protected void tryAgain() {
		// TODO Auto-generated method stub

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent intent = null;
		switch (v.getId()) {
		case R.id.modify_pw:
			intent = new Intent(mContext, ModifyPasswordActivity.class);
			startActivity(intent);
			break;

		case R.id.bind_phone:
			intent = new Intent(mContext, BindPhoneActivity.class);
			startActivity(intent);
			break;
		case R.id.exit: //退出登录
//			intent = new Intent(mContext, LoginActivity.class);
//			startActivity(intent);
			createDialog();
			break;
		default:
			break;
		}
	}

	private void createDialog() {
		// TODO Auto-generated method stub
		BaseAnimatorSet bas_in = new BounceTopEnter();
		BaseAnimatorSet bas_out = new SlideBottomExit();
		final NormalDialog dialog = new NormalDialog(getActivity());
		
		dialog.content("亲,真的要走吗?再看会儿吧~(●—●)")
				//
				.style(NormalDialog.STYLE_TWO)
				//
				.titleTextSize(23)
				//
				.btnText("继续逛逛", "残忍退出")
				//
				.btnTextColor(Color.parseColor("#383838"),
						Color.parseColor("#D4D4D4"))//
				.btnTextSize(16f, 16f)//
				.showAnim(bas_in)//
				.dismissAnim(bas_out)//
				.show();

		dialog.setOnBtnClickL(new OnBtnClickL() {
			@Override
			public void onBtnClick() {
				dialog.dismiss();
			}
		}, new OnBtnClickL() {
			@Override
			public void onBtnClick() {
//				SharedUtils.getInstance().ClearUser();   //清除sp中数据
//				new AccessTokenKeeper(mContext).clearAccessToken(mContext);   //清除token
//				MyApplication.getInstance().clearAccessToken(); 
				dialog.superDismiss();
//				startActivity(LoginActivity.class);
//				finish();
			}
		});

	
	}

}
